package org.bookshare.validator.report;

import java.io.File;
import java.util.Arrays;

import org.benetech.collections.ListMap;
import org.bookshare.document.beans.DocumentComponent;


/**
 * Generates information for the report about the files that are in the package.
 * @author Reuben Firmin
 */
public final class FileContentsReportGenerator implements ReportGenerator  {

	/**
	 * Default constructor.
	 */
	public FileContentsReportGenerator() {
		// empty
	}

    /**
     * {@inheritDoc}
     */
    public void addToReport(final ValidationMetadata report) {
        final ListMap<String, File> fileContents = new ListMap<String, File>();
        if (report.getDocumentSet().getType().containsComponent(DocumentComponent.OPF)) {
        	fileContents.put("opf", report.getDocumentSet().getFiles(DocumentComponent.OPF));
        }
        if (report.getDocumentSet().getType().containsComponent(DocumentComponent.XML)) {
        	fileContents.put("xml", report.getDocumentSet().getFiles(DocumentComponent.XML));
        }
        if (report.getDocumentSet().getType().containsComponent(DocumentComponent.PDF)) {
        	fileContents.put("pdf", report.getDocumentSet().getFiles(DocumentComponent.PDF));
        }
        if (report.getDocumentSet().getType().containsComponent(DocumentComponent.IMAGE)) {
        	fileContents.put("img", report.getDocumentSet().getFiles(DocumentComponent.IMAGE));
        }
        fileContents.put("other", report.getDocumentSet().getOtherFiles());
        report.getModelMap().put(getModelKey(), fileContents);
    }

    /**
     * {@inheritDoc}
     */
    public String getModelKey() {
        return "files";
    }

}


